package com.yc.yyds.servlet;

import com.yc.yyds.Bean.Result;
import com.yc.yyds.biz.BizException;
import com.yc.yyds.biz.IndentBiz;
import com.yc.yyds.util.ToJsonUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.Date;
import java.util.Map;

@WebServlet(name = "CancelIndentServlet", value = "/CancelIndentServlet.s")
public class CancelIndentServlet extends HttpServlet {
    IndentBiz biz = new IndentBiz();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        final String indentid = request.getParameter("indentid");
        final String userid = request.getParameter("userid");
        String starttime = request.getParameter("starttime");
        String ppjhid = request.getParameter("ppjhid");
        Long time = Long.valueOf(starttime);
        Result result ;
        try {
            Map<String, Object> userMsg = biz.cancel(indentid, userid,time,ppjhid);
            request.getSession().setAttribute("userMsg",userMsg);
            result= new Result(1,"订单取消成功!",null);
            ToJsonUtil.toJson(response,result);
        } catch (BizException e) {
            e.printStackTrace();
            result= new Result(0,e.getMessage(),null);
            ToJsonUtil.toJson(response,result);
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
